<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /**
     * @param {number[][]} moves
     * @return {string}
     */
    var tictactoe = function (moves) {
      let arr = [
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]
      ];

      for (let i = 0; i < moves.length; i++) {
        if (i % 2 === 0) {
          arr[moves[i][0]][moves[i][1]] = "x"
        } else {
          arr[moves[i][0]][moves[i][1]] = "o"
        }
      }

      for (let i = 0; i < arr.length; i++) {
        let result = arr[i].reduce((total, value) => {
          return total + value
        }, '')
        if (result === 'xxx') {
          return 'A'
        } else if (result === 'ooo') {
          return 'B'
        }
      }

      for (let i = 0; i < arr.length; i++) {
        let result = arr.reduce((total, value) => {
          return total + value[i]
        }, '')
        if (result === 'xxx') {
          return 'A'
        } else if (result === 'ooo') {
          return 'B'
        }
      }

      if (arr[0][0] + arr[1][1] + arr[2][2] === 'xxx') {
        return 'A'
      } else if (arr[0][0] + arr[1][1] + arr[2][2] === 'ooo') {
        return 'B'
      }

      if (arr[0][2] + arr[1][1] + arr[2][0] === 'xxx') {
        return 'A'
      } else if (arr[0][2] + arr[1][1] + arr[2][0] === 'ooo') {
        return 'B'
      }

      for (let i = 0; i < arr.length; i++) {
        for (let j = 0; j < arr.length; j++) {
          if (arr[i][j] === 0) {
            return 'Pending'
          }
        }
      }

      return "Draw"
    };

    console.log(tictactoe(
    [[0,0],[1,1]]
    ));
  </script>
</body>

</html>